package com.delicious.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.delicious.dao.impl.CategoryDaoImpl;
import com.delicious.dao.impl.FoodsDaoImpl;
import com.delicious.entity.Category;
import com.delicious.entity.Foods;

public class GetFoodsServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int id = 0;
		if(request.getParameter("id") != null && !request.getParameter("id").isEmpty())
			id = Integer.parseInt(request.getParameter("id"));
		
		List<Category> clist = new CategoryDaoImpl().getList();

		Foods f = new FoodsDaoImpl().getFoodByID(id);
		
		request.setAttribute("food", f);
		request.setAttribute("list", clist);
		request.getRequestDispatcher("foodsManager.jsp").forward(request, response);
	}

}
